package com.springboot.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.springboot.po.DeliveryAddress;
import com.springboot.service.DeliveryAddressService;

@RestController
@RequestMapping(path = "/DeliveryAddressController", method = RequestMethod.POST)
public class DeliveryAddressController {

	@Autowired
	DeliveryAddressService deliveryAddressService;
	
	@RequestMapping("/listDeliveryAddressByUserId")
	public List<DeliveryAddress> listDeliveryAddressByUserId(String userId)throws Exception{
		return deliveryAddressService.listDeliveryAddressByUserId(userId);
	}
	//CRUD
	@RequestMapping("/getDeliveryAddressById")
	public DeliveryAddress getDeliveryAddressById(Integer daId)throws Exception {
		return deliveryAddressService.getDeliveryAddressById(daId);
	}

	@RequestMapping("/saveDeliveryAddress")
	public int saveDeliveryAddress(DeliveryAddress deliveryAddress) throws Exception{
		return deliveryAddressService.saveDeliveryAddress(deliveryAddress);
	}

	@RequestMapping("/updateDeliveryAddress")
	public int updateDeliveryAddress(DeliveryAddress deliveryAddress)throws Exception {
		return deliveryAddressService.updateDeliveryAddress(deliveryAddress);
	}

	@RequestMapping("/removeDeliveryAddress")
	public int removeDeliveryAddress(Integer daId)throws Exception {
		return deliveryAddressService.removeDeliveryAddress(daId);
	}

}
